package com.atguigu.guli.service.edu.controller.admin;


import com.atguigu.guli.service.edu.entity.Chapter;
import com.atguigu.guli.service.edu.entity.Video;
import com.atguigu.guli.service.edu.service.VideoService;
import com.atguigu.guli.service.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2021-06-23
 */
@RestController
@RequestMapping("/edu/video")

public class AdminVideoController {
    @Autowired
    VideoService videoService;

    @GetMapping("/getVideoById/{id}") //根据id查数据
    public R getVideoById(@PathVariable String id){
        Video video = videoService.getById(id);
        return R.ok().data("list",video);
    }

    @DeleteMapping("/del/{id}")  //删除
    public R del(@PathVariable String id){
        videoService.removeById(id);
        return R.ok();
    }


    @PostMapping("/add") //添加章节
    public R add(@RequestBody Video video){
        videoService.save(video);
        return R.ok();
    }

    @PutMapping("/edit")  //修改
    public R edit(@RequestBody Video video){
        videoService.updateById(video);
        return R.ok();
    }



}

